<template>
	<view>
		<view class="container">
			<view class="table-view">
				<!-- <view class="title">账单明细</view> -->
				<view class="date-row">
					<view class="left">
						<picker mode="date" fields="month" @change="onDateChange">
							{{date.format('yyyy年MM月')}}
							<uni-icons type="bottom"></uni-icons>
						</picker>
					</view>
					<view class="right">
						<view class="item">收入：{{ income }}¥</view>
						<!-- <view class="item">提现：¥2839.00</view> -->
					</view>
				</view>
				<view class="item-row" v-for="(item,index) in info">
					<view class="left">
						<view class="name">订单到账</view>
						<view class="date">{{ item.createTime }}</view>
					</view>
					<view class="right sub-text">+{{ item.amount }}</view>
				</view>
				
			</view>
			
		</view>
	</view>
</template>

<script>
import * as nurseInfo from '../../common/api/nurseInfo.js'
	export default {
		data() {
			return {
				date:null,
				uid:'',
				income:'',
				info: [],
			}
		},
		onLoad(opt) {
			if (opt.uid) {
				this.uid = opt.uid
			}
			this.date = new Date()
		},
		onShow() {
			this.getData()
		},
		methods: {
			onDateChange(e){
				// console.log('数据返回',e.detail.value);
				const data = e.detail.value
				// const data = JSON.parse(dataJson) || {}
				const param = {
					uid: this.uid,
					date:data,
				}
				nurseInfo.queryByOrder(param).then(result => {
					this.info = result.data.data.queryByOrderDOList
					this.income = result.data.data.income
					console.log('数据返回',this.info);
				}).catch(error => {
					console.log(error);
				})
			},
			getData() {
				const dataJson = uni.getStorageSync('user_info') || '{}'
				console.log('user_info dataJson', dataJson);
				const data = JSON.parse(dataJson) || {}
				const param = {
					uid: data.nurseUid,
				}
				nurseInfo.queryByOrder(param).then(result => {
					this.info = result.data.data.queryByOrderDOList
					this.income = result.data.data.income
					console.log('数据返回',this.info);
				}).catch(error => {
					console.log(error);
				})
			},
		}
	}
</script>

<style>
	page{
		background: white;
	}
</style>
<style lang="scss" scoped>
.container{
	display: flex;
	flex-direction: column;
}

.table-view{
	width: 100%;
	display: flex;
	flex-direction: column;
	background: white;
	padding: 40rpx;
	box-sizing: border-box;
	.title{
		color: #232323;
		font-size: 32rpx;
		font-weight: 600;
	}
	.date-row{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 32rpx;
		.left{
			font-size: 36rpx;
			color: #232323;
			display: flex;
			align-items: center;
		}
		.right{
			display: flex;
			align-items: center;
			.item{
				margin-left: 24rpx;
				color: #232323;
				font-size: 24rpx;
			}
		}
	}
	
	.item-row{
		min-height: 146rpx;
		border-bottom: solid 2rpx #F8F8F8;
		display: flex;
		align-items: center;
		.left{
			flex: 1;
			.name{
				color: #232323;
				font-size: 32rpx;
				font-weight: 400;
			}
			.date{
				color: rgba(35,35,35,0.5);
				font-size: 24rpx;
				font-weight: 400;
				margin-top: 10rpx;
			}
		}
		.right{
			font-size: 36rpx;
			font-weight: 500;
		}
		.add-text{
				color: #2EB0D9;
		}
		.sub-text{
			color: #232323;
		}
	}
	
}

</style>
